#!/usr/bin/env bash
# extracting command line options and values

# 处理带值的选项
# 有些选项会带上一些额外的参数值

#./test17.sh -a -b test1 -d
#./test17.sh -ac	# 不能工作了

echo
while [ -n "$1" ]; do
	case "$1" in
	-a) echo "Found the -a option" ;;
	-b)
		param="$2"
		echo "Found the -b option, with parameter value $param"
		shift
		;;
	-c) echo "Found the -a option" ;;
	--)
		shift
		break
		;;
	*) echo "$1 is not an option" ;;
	esac
	shift
done
